<template>
    <div>
        <!--卡片-->
        <el-card class="box-card">
            <!--定义面包屑-->
            <el-breadcrumb separator=">">
                <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
                <el-breadcrumb-item>客户管理</el-breadcrumb-item>
                <el-breadcrumb-item>积分记录</el-breadcrumb-item>
            </el-breadcrumb>
            <el-divider></el-divider>
            <!--表单的搜索框
                 :model="双向绑定表单的数据"
            -->
            <el-form :inline="true" :model="integrationFormData"  class="demo-form-inline">
                <el-form-item >
                    <el-input v-model="integrationFormData.username" placeholder="请输入客户账号"></el-input>
                </el-form-item>
                <el-form-item >
                    <el-input v-model="integrationFormData.integrationType" placeholder="请输入积分类型"></el-input>
                </el-form-item>
                <el-form-item >
                    <el-select v-model="integrationFormData.changeType" clearable placeholder="请选择积分改变种类">
                        <el-option
                                v-for="item in options"
                                :key="item.value"
                                :label="item.lable"
                                :value="item.value">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="getAllIntegration()">查询</el-button>
                </el-form-item>
            </el-form>

            <!--数据表格-->
            <template>
                <el-table
                        :data="tableData"
                        :border="true"
                        stripe
                        style="width: 100%">
                    <el-table-column
                            prop="id"
                            label="积分ID">
                    </el-table-column>
                    <el-table-column
                            prop="clientId"
                            label="会员ID">
                    </el-table-column>
                    <el-table-column
                            prop="clientUser.username"
                            label="会员账号">
                    </el-table-column>
                    <el-table-column
                            prop="createTime"
                            label="创建时间">
                    </el-table-column>
                    <el-table-column
                            prop="changeType"
                            label="改变类型">
                        <template slot-scope="scope">
                            <span v-if="scope.row.changeType==0">减少积分</span>
                            <span v-if="scope.row.changeType==1">增加积分</span>
                        </template>
                    </el-table-column>
                    <el-table-column
                            prop="changeCount"
                            label="积分数量">
                    </el-table-column>
                    <el-table-column
                            prop="historyIntegration"
                            label="历史积分">
                    </el-table-column>
                    <el-table-column
                            prop="existingIntegration"
                            label="现有积分">
                    </el-table-column>
                    <el-table-column
                            prop="integrationType"
                            label="积分类型">
                    </el-table-column>
                </el-table>

                <!--分页-->
                <el-pagination
                        @size-change="handleSizeChange"
                        @current-change="handleCurrentChange"
                        :current-page="pageUtil.currentPage"
                        :page-sizes="[2,5,10,15,20]"
                        :page-size="pageUtil.pageSize"
                        layout="total, sizes, prev, pager, next, jumper"
                        :total="total">
                </el-pagination>
            </template>
        </el-card>
    </div>
</template>

<script>
    import qs from 'qs'
    export default {
        name: "ShowIntegration",

        data(){
            return {
                options:[
                    {
                        value:'0',
                        lable:'减少积分'
                    },
                    {
                        value:'1',
                        lable:'增加积分'
                    }
                ],

                //条件搜索对象
                integrationFormData:{
                    username:'',
                    integrationType:'',
                    changeType:''
                },
                //表格数据
                tableData:[],
                pageUtil:{
                    //每页显示的条数
                    pageSize: 5,
                    //当前的显示的页码
                    currentPage:0,
                },
                //总条数
                total:0,
            }
        },
        methods:{

            // 根据条件查询积分记录信息
            getAllIntegration() {
                this.$axios({
                    method:'post',
                    url:'clms-client/integration/getAllIntegration',
                    params:{
                        currentPage: this.pageUtil.currentPage,
                        pageSize: this.pageUtil.pageSize
                    },
                    data:qs.stringify(this.integrationFormData)
                }).then(r=>{
                        this.total = r.data.object;
                        this.tableData = r.data.listData;
                })
            },
            // 改变每页显示的条数时触发该方法
            handleSizeChange(val){
                alert(val)
                this.pageUtil.pageSize = val;
                this.getAllIntegration();
            },
            //切换页码时触发该方法
            handleCurrentChange(val){
                this.pageUtil.currentPage = val;
                this.getAllIntegration();
            }

        },

        // 钩子函数
        created() {
            // 根据条件查询积分记录信息
            this.getAllIntegration();
        }
    }

</script>

<style >

</style>